home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-03 / qbasicpg.zip / DIARY.BAS < prev    next >
BASIC Source File  |  1989-08-31  |  2KB  |  47 lines

  1. ' DIARY.BAS
  2. ' This program maintains a computer diary in a sequential file
  3. '   named DIARY.TXT.
  4.  
  5. CLS
  6.  
  7. OPEN "DIARY.TXT" FOR APPEND AS #1   ' open file in append mode
  8.  
  9. PRINT "Enter your secret thoughts for today; type END to quit."
  10. PRINT
  11.  
  12. PRINT #1, TIME$; "  "; DATE$        ' write time and date to file
  13. PRINT #1,                           ' write blank line to file
  14.  
  15. DO WHILE (UCASE$(line$) <> "END")   ' until user types "END",
  16.     LINE INPUT line$                '   get lines of text
  17.     IF (line$ <> "END") THEN PRINT #1, line$
  18. LOOP                                '   and write them to the file
  19.  
  20. PRINT #1,                           ' write blank line to file
  21. CLOSE #1                            ' close file
  22.  
  23. PRINT                               ' find out if user wants a printout
  24. INPUT "Would you like to print out your entire diary (Y,N)?  ", reply$
  25.  
  26. IF (UCASE$(reply$) = "Y") THEN        ' if yes,
  27.     OPEN "DIARY.TXT" FOR INPUT AS #1  '   open file for input
  28.    
  29.     LPRINT STRING$(33, "-");        ' print a header at top of page
  30.     LPRINT " My Diary ";
  31.     LPRINT STRING$(33, "-")
  32.     LPRINT                          '   and a blank line
  33.  
  34.     DO WHILE (NOT EOF(1))           ' until end of file is reached,
  35.        LINE INPUT #1, line$         '   read lines from file
  36.        LPRINT line$                 '   and send them to printer
  37.     LOOP
  38.  
  39.     CLOSE #1                        ' close file
  40.  
  41.     LPRINT CHR$(12)                 ' send formfeed character
  42.  
  43.     PRINT                           ' display message indicating diary
  44.     PRINT "Diary sent to printer"   '   contents have been sent to
  45. END IF                              '   printer
  46.  
  47.